﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Sympol
{
    public partial class Eval
    {

        public class Expression
        {
            public virtual string StringValue {
                get { return "Invalid Expression";  }
            }   
        }
        public class Return : Expression
        {
            public Value OfValue { get; set; }
            public override string StringValue
            {
                get { return "return " + OfValue.StringValue; }
            }
        }
        public class Value : Expression
        {
            public object Data { get; set; }
        }
        public class String : Value
        {
            public string StringData {get { return (string) Data; } set { Data = (object) value; }}
            public override string StringValue
            {
                get { return "'" + StringData.Replace("'", "\\'") + "'"; }
            }
        }
        public class Number : Value
        {
            public double NumberData {get { return (double) Data; } set { Data = (object) value; }}
            public override string StringValue
            {
                get { return NumberData.ToString(); }
            }
        }
        public class Reference : Value
        {
            public string Name { get; set; }
            public Value OfValue { get; set; }
            public override string StringValue
            {
                get { return Name + " " + OfValue.StringValue; }
            }
        }
        public class Object : Value
        {
            public IEnumerable<Reference> Members { get; set; }
            public override string StringValue
            {
                get
                {
                    var sw = new StringWriter();
                    sw.WriteLine("{");
                    Members.ToList().ForEach(m => sw.WriteLine(m.StringValue));
                    sw.WriteLine("}");
                    return sw.ToString();
                }
            }
        }
        public class Function
        {
            public IEnumerable<string> Params { get; set; }
            public IEnumerable<Expression> Expressions { get; set; } 
        }

        public class Boolean : Value
        {
            public class True : Boolean
            {
                    public override string StringValue {get { return "true"; }}
            }

            public class False : Boolean
            {
                       public override string StringValue {get { return "true"; }}
            }
        }
    }
}
